<!doctype html>
<html>
    <head>
        <title>VideoTrack properties read from input stream metadata</title>
        <script src="../../resources/testharness.js"></script>
        <script src="../../resources/testharnessreport.js"></script>
            </head>
    <body>
        <script>
            async_test(function(t)
            {
                var video = document.createElement("video");
                video.src = "../content/test.webm";

                video.onloadedmetadata = t.step_func_done(function()
                {
                    assert_equals(video.videoTracks.length, 1, "videoTracks.length");
                    assert_true(video.videoTracks[0].selected, "videoTrack.selected");
                    assert_equals(video.videoTracks[0].id, "1", "videoTrack.id");
                    assert_equals(video.videoTracks[0].kind, "main", "videoTrack.kind");
                    assert_equals(video.videoTracks[0].label, "", "videoTrack.label");
                    assert_equals(video.videoTracks[0].language, "", "videoTrack.language");
                });
            });
            async_test(function(t)
            {
                var canvas1 = document.createElement("canvas");
                canvas1.getContext('2d').fillRect(0, 0, canvas1.width, canvas1.height);
                var stream1 = canvas1.captureStream();

                var canvas2 = document.createElement("canvas");
                canvas2.getContext('2d').fillRect(0, 0, canvas2.width, canvas2.height);
                var stream2 = canvas2.captureStream();

                var video = document.createElement("video");
                var tracks = [...stream1.getTracks(), ...stream2.getTracks()];
                var stream = new MediaStream(tracks);
                video.srcObject = stream;
                video.onloadedmetadata = t.step_func_done(function()
                {
                    assert_equals(video.videoTracks.length, 2, "videoTracks.length");

                    assert_true(video.videoTracks[0].selected, "videoTrack.selected");
                    assert_true("id" in video.videoTracks[0], "videoTrack.id");
                    assert_equals(video.videoTracks[0].kind, "main", "videoTrack.kind");
                    assert_true("label" in video.videoTracks[0], "videoTrack.label");
                    assert_equals(video.videoTracks[0].language, "", "videoTrack.language");

                    assert_false(video.videoTracks[1].selected, "videoTrack.selected");
                    assert_true("id" in video.videoTracks[1], "videoTrack.id");
                    assert_equals(video.videoTracks[1].kind, "main", "videoTrack.kind");
                    assert_true("label" in video.videoTracks[1], "videoTrack.label");
                    assert_equals(video.videoTracks[1].language, "", "videoTrack.language");
                });
            });
        </script>
    </body>
</html>
